package com.soup.common.module.sys.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.soup.common.constant.CommonConstant;
import com.soup.common.entity.BaseEntity;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;

/**
 * 权限角色模型
 *
 * @author zhaoyi
 */
@Data
@Table(name = CommonConstant.SYS_ROLE)
public class Role extends BaseEntity {

    /**
     * 角色名称
     */
    @NotBlank(message = "角色权限名不能为空")
    @Length(max = 32, message = "角色权限名长度过长")
    private String name;

    /**
     * 角色描述
     */
    @Length(max = 64, message = "角色权限名长度过长")
    private String description;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date gmtCreate;

    /**
     * 角色分配的菜单id
     */
    @Transient
    private List<Integer> menuIds;
}
